<?php
/**
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       Cake.View.Layouts
 * @since         CakePHP(tm) v 0.10.0.1076
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

$cakeDescription = __d('cake_dev', 'FAPES: Administradora de Benefícios - testando....');
//echo $this->Html->meta()
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Saúde Servidor FAPES :: Administradora de Benefícios</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php echo $this->Html->meta('favicon.ico', $this->webroot.'img/favicon.ico', array('type' => 'icon')); ?>

<?php echo $this->Html->css('reset'); ?>
<!--  <link rel="stylesheet" href="css/reset.css" type="text/css" charset="utf-8"> -->

<?php echo $this->Html->css('style'); ?>
<!-- <link href="<?php echo $this->webroot; ?>css/style.css" rel="stylesheet" type="text/css" />  -->

<?php echo $this->Html->css('coin-slider'); ?>
<!-- <link href="<?php echo $this->webroot; ?>css/coin-slider.css" rel="stylesheet" type="text/css" /> --> 


<?php echo $this->Html->css('core'); ?>
<!--  <link rel="stylesheet" href="css/core.css" type="text/css" charset="utf-8"> -->

<?php echo $this->Html->css('accordion.core'); ?>
<!--  <link rel="stylesheet" href="css/accordion.core.css" type="text/css" charset="utf-8"> -->

<?php echo $this->Html->css('jsDatePick_ltr.min'); ?>
<!--  <script type="text/javascript" src="js/jsDatePick.min.1.3.js" charset="utf-8"></script> -->

<?php echo $this->Html->script('jsDatePick.min.1.3'); ?>
<!-- <script src="<?php echo $this->webroot; ?>js/jsDatePick.min.1.3.js" type="text/javascript" ></script> -->

<?php echo $this->Html->script('cufon-yui'); ?>
<!-- <script src="<?php echo $this->webroot; ?>js/cufon-yui.js" type="text/javascript" ></script> -->

<?php echo $this->Html->script('cufon-georgia'); ?>
<!-- <script type="text/javascript" src="<?php echo $this->webroot; ?>js/cufon-georgia.js"></script> -->

<?php echo $this->Html->script('jquery-1.4.2.min'); ?>
<!-- <script type="text/javascript" src="<?php echo $this->webroot; ?>js/jquery-1.4.2.min.js"></script> -->

<?php echo $this->Html->script('script'); ?>
<!-- <script type="text/javascript" src="<?php echo $this->webroot; ?>js/script.js"></script> -->

<?php echo $this->Html->script('coin-slider.min'); ?>
<!-- <script type="text/javascript" src="<?php echo $this->webroot; ?>js/coin-slider.min.js"></script> -->

<?php echo $this->Html->script('jquery.accordion.2.0'); ?>
<!--  <script type="text/javascript" src="js/jquery.accordion.2.0.js" charset="utf-8"></script> -->

<?php echo $this->Html->script('jquery.maskedinput'); ?>
<!--  <script type="text/javascript" src="js/jquery.maskedinput.js" charset="utf-8"></script> -->



<!--TERMS OF USE. DON'T EDIT OR DELETE THESE LINES. IF YOU EDIT OR DELETE THESE LINES AN ALERT MESSAGE MAY APPEAR WHEN TEMPLATE WILL BE ONLINE-->
	<style>		#my-header-new a,#my-header-new a:hover {color:#c2cae0;}#my-header-new a:hover {text-decoration:none}</style>
	<!--TERMS OF USE-->
</head>

<!-- -----------------------------body------------------------------------->

<?php echo $this->fetch('content'); ?>

<!-- -----------------------------endbody---------------------------------->

<script type="text/javascript">
function changeBackground(color) {
	document.body.style.background = color;
	document.getElementById('mainlogo').style.height = '81px';
	document.getElementById('mainlogo').style.background = '#ffffff';
	document.getElementById('contentpage').style.minHeight = ($(window).height()-302)+'px';

	//alert("teste");
	var $items = $('#vtab>ul>li');
	$items.click(function() {
		$items.removeClass('selected');
		$(this).addClass('selected');

		
		var index = $items.index($(this));
		$('#vtab>div').hide().eq(index).show();
	}).eq(0).click();

	document.getElementById("numdependentescliente").value = 0;
	

	/* ------- data picker ----------- */
	//new JsDatePick({
	//	useMode:2,
	//	target:"datanasccliente",
	//	dateFormat:"%d/%m/%Y",
		/*selectedDate:{				This is an example of what the full configuration offers.
			day:5,						For full documentation about these settings please see the full version of the code.
			month:9,
			year:2006
		},*/
		//yearsRange:[1952,2013],
	//	limitToToday:true,
	//	cellColorScheme:"ocean_green",
		//dateFormat:"%m-%d-%Y",
	//	imgPath:<?php //echo $this->webroot; ?>+"img/datapicker/",
	//	weekStartDay:0
	//});

	// new JsDatePick({
	//	useMode:2,
	//	target:"inputField1",
	//	dateFormat:"%d/%m/%Y",
		/*selectedDate:{				This is an example of what the full configuration offers.
			day:5,						For full documentation about these settings please see the full version of the code.
			month:9,
			year:2006
		},*/
	//	yearsRange:[1952,2013],
	//	limitToToday:true,
	//	cellColorScheme:"ocean_blue",
		//dateFormat:"%m-%d-%Y",
	//	imgPath:"../img/",
	//	weekStartDay:0
	//});
}

$("#accordion > li").click(function(){

	if(false == $(this).next().is(':visible')) {
		$('#accordion > ul').slideUp(300);
	}
	$(this).next().slideToggle(300);
});

//$('#accordion > ul:eq(0)').show();

$(document).ready(function(){
	$("input.datanasccliente").mask("99/99/9999");
    $("input.cpfcliente").mask("999.999.999-99");
    $("input.cepcliente").mask("99.999-999");
    
    //$("input.fonecomercialcliente").mask("(99)999999999");
    
});

function validaEmail() {
	if(document.getElementById('emailcliente').value != document.getElementById('confirmaemailcliente').value ) {
		document.getElementById('emailcliente').title = "Os e-mails não conferem!";
		document.getElementById('emailcliente').style.backgroundColor = '#FFABAB';

		document.getElementById('confirmaemailcliente').title = "Os e-mails não conferem!";
		document.getElementById('confirmaemailcliente').style.backgroundColor = '#FFABAB';
	} else {
		document.getElementById('emailcliente').title = "";
		document.getElementById('emailcliente').style.backgroundColor = '#FFFFFF';

		document.getElementById('confirmaemailcliente').title = "";
		document.getElementById('confirmaemailcliente').style.backgroundColor = '#FFFFFF';
	}
}
	

function valida_cpf(input){
	var cpf = input.value;
	
	cpf = cpf.replace('.', '');
	cpf = cpf.replace('.', '');
	cpf = cpf.replace('-', '');
	
    var numeros, digitos, soma, i, resultado, digitos_iguais;
    digitos_iguais = 1;
    
    if (cpf.length < 11) {
    	input.title = "CPF Inválido!";
    	input.style.backgroundColor = '#FFABAB';
    	input.value = cpf;
    	//alert("CPF inválido");
        return false;
    }
    
    for(i = 0; i < cpf.length - 1; i++) {
        if(cpf.charAt(i) != cpf.charAt(i + 1)) {
            digitos_iguais = 0;
            break;
        }
    }
    
    if(!digitos_iguais) {

        numeros = cpf.substring(0,9);
        digitos = cpf.substring(9);
        soma = 0;

        for(i = 10; i > 1; i--) {
            soma += numeros.charAt(10 - i) * i;
        }

        resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;

        if(resultado != digitos.charAt(0)) {
        	input.title = "CPF Inválido!";
        	input.style.backgroundColor = '#FFABAB';
            return false;
        }

        numeros = cpf.substring(0,10);
        soma = 0;

        for(i = 11; i > 1; i--) {
            soma += numeros.charAt(11 - i) * i;
        }

        resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
        if(resultado != digitos.charAt(1)) {
        	input.title = "CPF Inválido!";
        	input.style.backgroundColor = '#FFABAB';
            return false;
        }

        input.title = "";
        input.style.backgroundColor = '#FFFFFF';
        
        //alert("CPF válido");
        return true;
          
    } else {
    	input.title = "CPF Inválido!";
    	input.style.backgroundColor = '#FFABAB';
    	return false;
    }
}

function validaDat(input) {
	var date = input.value;
	var ardt=new Array;
	var ExpReg=new RegExp("(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/[12][0-9]{3}");
	ardt=date.split("/");
	erro=false;
	//alert("teste");
	if ( date.search(ExpReg)==-1){
		erro = true;
		}
	else if (((ardt[1]==4)||(ardt[1]==6)||(ardt[1]==9)||(ardt[1]==11))&&(ardt[0]>30))
		erro = true;
	else if ( ardt[1]==2) {
		if ((ardt[0]>28)&&((ardt[2]%4)!=0))
			erro = true;
		if ((ardt[0]>29)&&((ardt[2]%4)==0))
			erro = true;
	}
	if (erro) {
		//alert("\"" + valor + "\" não é uma data válida!!!");
		input.focus();
		//campo.value = "";
		input.title = "Data Inválida!";
        input.style.backgroundColor = '#FFABAB';
		return false;
	}
	input.title = "";
    input.style.backgroundColor = '#FFFFFF';
    
	return true;
}

function consultarCEP(input) {
		
	var cep = input.value;
	
	cep = cep.replace('.', '');
	cep = cep.replace('-', '');
	
	 $.ajax({
	   type:'post', 
	    dataType:'json',
	   url:'/site/clientes/showdata/',
	   data: {"cep": cep},
	   success: function(r) {
		
	    if(r.status) {
	    	document.getElementById('enderecocliente').value = r.rua;
	    	document.getElementById('bairrocliente').value = r.bairro;
	    	document.getElementById('cidadecliente').value = r.cidade;
	    	document.getElementById('estadocliente').value = r.estado;

	    	/*$("input.fonecomercialcliente").unmask();
	    	$("input.fonecelularcliente").unmask();
	        $("input.foneresidencialcliente").unmask();
	    	
	    	if(r.estado == 'SP') {
	        	$("input.fonecomercialcliente").mask("(99)99999-9999");
	        	$("input.fonecelularcliente").mask("(99)99999-9999");
		        $("input.foneresidencialcliente").mask("(99)99999-9999");
	        } else {
	        	$("input.fonecomercialcliente").mask("(99)9999-9999");
	        	$("input.fonecelularcliente").mask("(99)9999-9999");
		        $("input.foneresidencialcliente").mask("(99)9999-9999");
	        }*/
	     }
	   }
	 });
	}


/*$(function(){
			$('.datepick').datepicker({
				inline: true,
				nextText: 'Próximo',
				prevText: 'Anterior',
				showOtherMonths: true,
				dateFormat: 'dd/mm/yy',
				dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],
    			dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
				monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
				monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
				//showOn: "button",
				//buttonImage: "img/calendar-blue.png",
				//buttonImageOnly: true,
			});
		});
*/

function validateTemFaixa(){
	if(OperadoraTemfaixa.checked == 1) {
		document.getElementById('op_div_textofaixa').disabled=false;
		document.getElementById('op_div_textofaixa').style.backgroundColor = '#FFFFFF';
		//alert("Teste");
	} else {
		document.getElementById('op_div_textofaixa').disabled=true;
		document.getElementById('op_div_textofaixa').style.backgroundColor = '#D3D3D3';
		document.getElementById('op_div_textofaixa').value = '';
	}
}

function validateOrgao(){
	var e = document.getElementById('ClienteOrgaoId');
	var stringOption = e.options[e.selectedIndex].text;
	if(stringOption == 'Outros') {
		document.getElementById('op_div_orgao').disabled=false;
		document.getElementById('op_div_orgao').style.backgroundColor = '#FFFFFF';
	} else {
		document.getElementById('op_div_orgao').disabled=true;
		document.getElementById('op_div_orgao').style.backgroundColor = '#D3D3D3';
		document.getElementById('op_div_orgao').value = '';
	}
}

function outContactButton() {
	document.getElementById('imageField').src = "<?php echo $this->webroot; ?>img/images/submit_out.gif";
}

function overContactButton() {
	document.getElementById('imageField').src = "<?php echo $this->webroot; ?>img/images/submit_hover.gif";
}

function outAddDependentButton() {
	document.getElementById('addDependentButton').src = "<?php echo $this->webroot; ?>img/adddependente_normal.gif";
}

function overAddDependentButton() {
	document.getElementById('addDependentButton').src = "<?php echo $this->webroot; ?>img/adddependente_down.gif";
}


function outRemoveDependentButton(input) {
	input.src = "<?php echo $this->webroot; ?>img/removedependente_normal.gif";
	/*document.getElementById('removeDental').style.background = '#fff -webkit-gradient(linear, left top, left bottom, from(#BBBBBB), to(#fff)) no-repeat';
	document.getElementById('removeDental').style.background = '-moz-linear-gradient(center top , #fff, #BBBBBB) repeat scroll 0 0 #fff';
	document.getElementById('removeDental').style.color = '#000';*/
	
	
	
}

function overRemoveDependentButton(input) {
	input.src = "<?php echo $this->webroot; ?>img/removedependente_down.gif";
	/*document.getElementById('removeDental').style.background = '#000 -webkit-gradient(linear, left top, left bottom, from(#373737), to(#000)) no-repeat';
	document.getElementById('removeDental').style.background = '-moz-linear-gradient(center top , #373737, #404040) repeat scroll 0 0 #000';
	document.getElementById('removeDental').style.color = '#fff';*/
}


function setImageOperadora(operadora_id) {
	alert("Teste"+operadora_id);
	//document.getElementById('operadora'+operadora_id).style.background = "url('<?php echo $this->webroot; ?>img/uploads/2.png') no-repeat center center";
	//background: url('../img/ProdentImagem.png') no-repeat center center;
}

function showopcontent(categoria_id) {
	alert("Teste: "+categoria_id);
	//operadora_id = "ajsgadjbas sk ksajhd l sahdl ahsljd";
	//var operadoras = '<li class="operadora1" style="background: url('+<?php echo $this->webroot; ?>+'img/uploads/2.png'+') no-repeat center center;"></li>';

	<?php 
		//echo $imagens = $this->Operadora->Imagem->find('all', array('conditions' => array('Imagem.id' =>  2)));
		//echo pr($imagens);
	?>
	
	//document.getElementById('ulteste').innerHTML = operadoras; 
}

function expandecategoria(input, catg_id) {
	
	if(document.getElementById('teste'+catg_id).style.height > '0px') {
		document.getElementById('teste'+catg_id).style.height = '0px';
		
	} else {
		document.getElementById('teste'+catg_id).style.height = input;
		
	}
}



function operadoradata(nk, catgID) {

	 $.ajax({
	   //type:'post',
	   //async: false,
	   //contentType: "application/json; charset=utf-8",
	   accepts: 'json',
	   type: 'POST',
	   dataType:'json',
	   url:'/site/operadoras/showdata/',
	   data: {"nk": nk},
	   success: function(r) {
		//alert(r.operadora);
		var operadora = eval(JSON.stringify(r.operadora));
	   	var entidade = eval(JSON.stringify(r.entidade));
		var detalhes = eval(JSON.stringify(r.detalhes));
	   	//alert("teste"); 
	    if(r.status) {
	    	//var contentoperadora = '<li class="operadora1" style="background: url('+<?php echo $this->webroot; ?>+'img/uploads/2.png'+') no-repeat center center;"></li>';
	    	//alert(operadora[0].Operadora.nome);
	    	var contentoperadora = '<fieldset>'
		    	+ '<legend align="center" style="clear: both; color: #FA8600; font-weight: bold; font-size: 20px;">ENTIDADE ESCOLHIDA</legend>'
		    	+ '<div id="entdiv" style="width: 100%; height: 89px;">'
		    	+ 		'<div id="entdiv1" style="float: left; position: relative; width: 30%;">'
		    	+			'<img src="'+<?php echo $this->webroot; ?>+entidade[0].Entidade.imgpath+'" />'
		    	+		'</div>'
		    	+ 		'<div id="entdiv2" style="color: #003d4c; float: left; padding-left: 20px; width: 65%; height: 100%; display: table;">'
		    	+ 			'<p style=" font-size: 17px;"><b>'+entidade[0].Entidade.nome+'</b></p>'
		    	+ 		'</div>'
		    	+ '</div>'
		    	+ '</fieldset>'
		    	+'<fieldset>'
		    	+ '<legend align="center" style="clear: both; color: #FA8600; font-weight: bold; font-size: 17px;">OPERADORA ESCOLHIDA</legend>'
		    	+ '<div id="entdiv" style="width: 100%; height: 89px;">'
		    	+ 		'<div id="entdiv3" style="float: left; position: relative; width: 20%;">'
		    	+			'<img src="'+<?php echo $this->webroot; ?>+operadora[0].Operadora.logopath+'" />'
		    	+		'</div>'
		    	+ 		'<div id="entdiv4" style="color: #003d4c; float: left; padding-left: 20px; width: 75%; height: 100%; display: table;">'
		    	+ 			'<p style=" font-size: 17px;"><b>'+operadora[0].Operadora.nome+'</b></p>'
		    	+			'<p style="font-size: 12px; color: #13A89D;"><b>Quem pode aderir: </b>'+entidade[0].Entidade.explicacao+'</p>'
		    	+ 		'</div>'
		    	+ '</div>'
		    	+ '</fieldset>'
		    	+ '<fieldset>'
		    	+ '<legend align="center" style="clear: both; color: #003d4c; font-weight: bold; font-size: 15px;">DETALHES DA OPERADORA</legend>'
		    	+ '<div id="entdivdetlhes" style="width: 100%; height: 100%;">'
		    	+ '<form method="post" action="adesao">'
		    	+	'<input name="operadoraID" type="hidden" value="'+operadora[0].Operadora.id+'">'
		    	+	'<input name="entidadeID" type="hidden" value="'+entidade[0].Entidade.id+'">'
		    	+	'<input name="categoriaID" type="hidden" value="'+catgID+'">'
				+ 	'<input type="submit" name="makeProposalButton" id="imageAddButton'+catgID+operadora[0].Operadora.id+'" alt="Submit form" style=" width: 632px; height: 50px;" value="FAÇA AQUI SUA INSCRIÇÃO" class="makeProposalButton" />'
				+ '</form>'
				+ '<br>';
			for(var i = 0; i < detalhes.length; i++) {
				if(detalhes[i].Operadoradetalhe.tipodetalhe == '0') {
					contentoperadora = contentoperadora + detalhes[i].Operadoradetalhe.descricao;
					i = detalhes.length;
				}
			}
				//+ detalhes[0].Operadoradetalhe.descricao
			contentoperadora = contentoperadora	+ '<br>'
				+ '<form method="post" action="adesao">'
				+	'<input name="operadoraID" type="hidden" value="'+operadora[0].Operadora.id+'">'
				+	'<input name="entidadeID" type="hidden" value="'+entidade[0].Entidade.id+'">'
				+	'<input name="categoriaID" type="hidden" value="'+catgID+'">'
				+ 	'<input type="submit" name="makeProposalButton" id="imageAddButton'+catgID+operadora[0].Operadora.id+'" alt="Submit form" style=" width: 632px; height: 50px;" value="FAÇA AQUI SUA INSCRIÇÃO" class="makeProposalButton" />'
				+ '</form>'
		    	+ '</div>'
		    	+'</fieldset>';
	    	
	    	document.getElementById('contentoperadora'+catgID+nk).innerHTML = contentoperadora;

	    	//<input type="image" name="imageField" id="imageAddButton1'+operadora[0].Operadora.id+'" src="'+<?php //echo $this->webroot; ?>+'img/addbutton_out.gif" alt="Submit form" style=" width: 632px; height: 50px;" onmouseover="overAddButton('+operadora[0].Operadora.id+');" onmouseout="outAddButton('+operadora[0].Operadora.id+');" class="send" />
	    	//alert(entidade[0].Entidade.nome);
			//alert(detalhes[0].Operadoradetalhe.titulo);
	     }
	   }
	 });
	}
	

//$('#example2, #example3').accordion();
$('#example1').accordion({
    canToggle: true
});
/*$('#example4').accordion({
    canToggle: true,
    canOpenMultiple: true
});*/
$(".loading").removeClass("loading");

function overAddButton(id) {
	document.getElementById('imageAddButton'+id).src = <?php echo $this->webroot; ?>+'img/addbutton_hover.gif';
	document.getElementById('imageAddButton1'+id).src = <?php echo $this->webroot; ?>+'img/addbutton_hover.gif';
}

function outAddButton(id) {
	document.getElementById('imageAddButton'+id).src = <?php echo $this->webroot; ?>+'img/addbutton_out.gif';
	document.getElementById('imageAddButton1'+id).src = <?php echo $this->webroot; ?>+'img/addbutton_out.gif';
}


/*$(function() {
	//alert("teste");
	var $items = $('#vtab>ul>li');
	$items.click(function() {
		$items.removeClass('selected');
		$(this).addClass('selected');

		
		var index = $items.index($(this));
		$('#vtab>div').hide().eq(index).show();
	}).eq(0).click();
});*/

</SCRIPT>
</html>
